package com.ccys.app.controller;

import cn.hutool.core.util.ObjectUtil;
import com.ccys.app.service.HistoryScreenService;
import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.cache.UserUtil;
import com.ccys.db.entity.TblMember;
import com.ccys.db.vo.app.historyScreen.GetBookingHistoryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: WhiteCoat
 * @description: 用户查看问诊记录接口
 * @author: ZhangJingCan
 * @create: 2024-01-28 16:16
 **/

@RestController
@Api(tags = "用户查看问诊记录接口")
@RequestMapping("historyScreen")
public class HistoryScreenController {

    @Autowired
    private HistoryScreenService historyScreenService;

    @ApiOperation("用户查看问诊记录-分页")
    @GetMapping(value = "/GetBookingHistory")
    public ResponseResultApp<GetBookingHistoryVo> getBookingHistory(Integer page_index, Integer page_size) {
        //校验分页参数必须传
        if (ObjectUtil.isEmpty(page_index) || ObjectUtil.isEmpty(page_size)) {
            return ResponseResultApp.error(400, "The page_index field is required.");
        }
        //校验是否登录
        TblMember member = UserUtil.getCurLoginMember();
        if (ObjectUtil.isEmpty(member)) {
            return ResponseResultApp.error(401, "Request require authorization.");
        }
        return historyScreenService.getBookingHistory(page_index, page_size, member.getId());
    }

}
